<?php
$adminList = "";
$obj = "\$object_$class";
$Uclass = strtoupper($class);
$colspan = count($var)+1;

$yuiFields = "";
/*
			var rowName = oArgs.record.getData("nome");
        	var postData = "id="+rowId+"&";
			postData = postData + "codigo="+rowBank+"&";
			postData = postData + "nome="+rowName+"&";
        			"id"=>$obj->id,
		"codigo"=>$obj->codigo,
		"nome"=>$obj->nome,
		"created_on"=>$obj->created_on,
		"updated_on"=>$obj->updated_on

* */
$jsonObj = "";
for ($i=0;$i<count($var);$i++){
	$jsonObj .= "\t\t".'"'.$var[$i]["name"].'"=>'.$obj.'->'.$var[$i]["name"].','.$CR;
}
$jsonObj = rtrim($jsonObj,",");

$adminList .= <<<html
<?php
include("../../config/config.php");
\$DM->loadClass("$package","$class");
// create and instance class

\$records = array();
// Define defaults
\$results = -1; // default get all
\$startIndex = 0; // default start at 0
\$sort = "id"; // default don't sort
\$dir = 'asc'; // default sort dir is asc
\$sort_dir = SORT_ASC;

// How many records to get?
if(strlen(\$_GET['results']) > 0) {
    \$results = \$_GET['results'];
}

// Start at which record?
if(strlen(\$_GET['startIndex']) > 0) {
    \$startIndex = \$_GET['startIndex'];
}

// Sorted?
if(strlen(\$_GET['sort']) > 0) {
    \$sort = \$_GET['sort'];
}

// Sort dir?
if((strlen(\$_GET['dir']) > 0) && (\$_GET['dir'] == 'desc')) {
    \$dir = 'desc';
    \$sort_dir = SORT_DESC;
}else {
    \$dir = 'asc';
    \$sort_dir = SORT_ASC;
}
$obj = new $class();
\$totalCount={$obj}->getCount();
{$obj}->getPage('',\$startIndex,\$results,\$sort,\$dir);

for (\$i=0;\$i<count({$obj}->lista);\$i++){
	{$obj}->id={$obj}->lista[\$i]["id"];
	{$obj}->getById();
	
	\$myar = array(
$jsonObj
	);
	array_push(\$records,\$myar);
}
\$jsReturn = array(
	"recordsReturned"=>count({$obj}->lista)+0,
	"totalRecords"=>\$totalCount+0,
	"startIndex"=>\$startIndex+0,
	"sort"=>\$sort,
	"dir"=>\$dir,
	"records"=>\$records
);
header('Content-type: application/json');
echo json_encode(\$jsReturn);
?>
html;

?>

